//////////////////////////////////////////////////////
//  Duck.h	- DUCK CHARACTER						//
//  Created : nvchuong								//
///////////////////////////////////////////////////////
#ifndef __ADU_DUCK_H__
#define __ADU_DUCK_H__

#include "cocos2d.h"
#include "ADUConfig.h"
#include <Box2D/Box2D.h>
#include <CCPhysicsSprite.h>
#include "GB2ShapeCache-x.h"
#include "ADUConstant.h"
#include "ADUGameManager.h"
#include "extensions/cocos-ext.h"
#include "ui/CocosGUI.h"
#include "ADUBasin.h"

using namespace ui;
using namespace std;
using namespace cocos2d;

class Basin;

USING_NS_CC_EXT;

class Duck : public Sprite, public b2BuoyancyMergeListener{
public:
	Duck();
	~Duck();

	static Duck* create(const string& file);
    
	void initialState();

	void setState(const int& _state);
	int getState() const;

	void setHealthStatus(const int& _healthValue);
	int getHealthStatus() const;
	void update(float dt);

	virtual void setPosition(const Vec2 &position);
	void integrateBox2D();

	b2Body* GetBody(){
		return m_duckBody;
	}
	void setBody(b2Body* _body) {
		m_duckBody = _body;
	}
	void syncWithPhysics();
	void syncWithSprite();
	void sync();
    virtual void onStartMerge(void);
    void addHealthBar();
    void fallInWater();
    void SetLastBindBasin(Basin* basin);
private:
	int m_state;
	int m_health;
	bool isDied;
    bool waterfalled;
    float deltaT;
	b2Body* m_duckBody;
	b2Fixture* m_duckFixture;
	Slider* healthBar;
    Basin*  mLastBindBasin;
};
#endif

